package com.mobiqueen.data;

import com.mobiqueen.generic.ApplicationException;

import android.app.Activity;
import android.database.Cursor;
import android.os.Bundle;
import android.util.Log;

public class getData extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        DatabaseAdapter db = new DatabaseAdapter(this);
        
        db.open();
        long id;
        boolean b;
        /*        
        id = db.insertPerformance("voorstelling 1", "a big popstar", "", "", "link naar de popostar", "", "", "2011-01-01 10:00:00", "2011-01-01 11:00:00", "pop", 0);
        Log.d("debug insertPerformance:", "" + id);
        boolean b = db.deletePerformance("name");
        Log.d("debug deletePerformance:", "" + b);
        Cursor c = db.getAllPerformances();
        c.moveToFirst();        
        Log.d("debug cursor count:", "" + c.getCount());
        c.close();
        */        
        id = db.insertPodium("podium1", 52.337293D, 4.874336D,"street podium 1", "91a", "1010JP", "AMS");
        Log.d("debug insertPodium:", "" + id);
        id = db.insertPodium("podium2", 52.376285D, 4.867555D,"street podium 2", "3", "1111AA", "AMS");
        Log.d("debug insertPodium:", "" + id);
        id = db.insertPodium("podium3", 52.376994D, 4.922318D,"street podium 3", "45", "1234XS", "AMS");
        Log.d("debug insertPodium:", "" + id);
        try {
        	b = db.deletePodium(id);
        	Log.d("delete podium", " " + id + ": " + b);
        }
        catch (ApplicationException e) {
        	Log.e("delete exception", e.toString());
        }
        
        Cursor cp = db.getAllPodiums();
        cp.moveToFirst();
        Log.d("debug cursor count:", "" + cp.getCount());
        cp.close();
        id = db.insertPerformance("voorstelling 1", "a big popstar", "", "", "link naar de popostar", "", "", "2011-01-01 10:00:00", "2011-01-01 11:00:00", "pop", 1);
        Log.d("debug insertPerformance:", "" + id);
        id = db.insertPerformance("voorstelling 2", "another big popstar", "", "", "link naar de popostar", "", "", "2011-01-01 11:00:00", "2011-01-01 12:00:00", "pop", 1);
        Log.d("debug insertPerformance:", "" + id);
        id = db.insertPerformance("voorstelling 3", "a very big big popstar", "", "", "link naar de popostar", "", "", "2011-01-01 13:00:00", "2011-01-01 13:00:00", "pop", 2);
        Log.d("debug insertPerformance:", "" + id);
        Cursor c = db.getAllPerformances();
        c.moveToFirst();        
        Log.d("debug cursor count:", "" + c.getCount());
        c.close();
        
        try {        	        
        	b = db.deletePodium(2);
        }
        catch (ApplicationException e) {
        	Log.e("delete exception", e.toString());
        }	
        
        db.close();        
    }
}